
package com.tdam2014.grupo01.adapters;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.util.List;

import com.tdam2014.grupo01.R;
import com.tdam2014.grupo01.interfaces.HTTPInterface;
import com.tdam2014.grupo01.objects.Photoset;

import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class PhotoSetListAdapter extends BaseAdapter {

	private List<Photoset> list;
	private LayoutInflater inflater;
	private Context context;

	public PhotoSetListAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
	}
	

	public void setList(List<Photoset> list) {
		this.list = list;
	}

	public void updateList(List<Photoset> list) {
		this.list.clear();
		this.list.addAll(list);
		this.notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		Holder holder = null;

		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_lista_directorio, null);
			holder = new Holder();
			holder.title = (TextView) convertView
					.findViewById(R.id.nombreDirectorioLista);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}

		TextView title = holder.title;
		Photoset photoSet = list.get(position);
		title.setText(photoSet.getTitle());
		
		return convertView;
	}

	static class Holder {
		
		TextView title;
	}	
}
